package com.hankol.newretail.viewmodel

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.baselibrary.base.BasicListBean
import com.baselibrary.bean.ReceiveAddressBean
import com.hankol.newretail.bean.*
import com.hankol.newretail.respository.NewReatilRequestManager

/**订单相关
 * @author: merbng
 * @time: 2022/8/5 9:56
 * @description:
 */
class OrderAboutViewModel : ViewModel() {
    var homeDataLD: MutableLiveData<HomeMallInfoBean> = MutableLiveData()

    //确认订单-->提交订单
    var commitOrderLD: MutableLiveData<CommitOrderBean> = MutableLiveData()

    //【确认订单】详情
    var orderDetailLD: MutableLiveData<OrderDetailBean> = MutableLiveData()

    //订单详情
    var orderLoadDetailLD: MutableLiveData<OrderLoadDetailBean> = MutableLiveData()

    //待付款超时
    var overTimeCancelLD: MutableLiveData<Any> = MutableLiveData()
    var overTimeReceiveLD: MutableLiveData<OverTimeReceiveBean> = MutableLiveData()

    //取消订单
    var cancelOrderLD: MutableLiveData<Any> = MutableLiveData()

    //地址列表
    var addressDataLD: MutableLiveData<List<ReceiveAddressBean>> = MutableLiveData()

    //纯酒币（无现金）_电商订单_生成支付订单
    var onlyScoreOrderLD: MutableLiveData<CreateScoreOrderBean> = MutableLiveData()

    //取消原因列表
    var cancelOrderReasonLD: MutableLiveData<List<CancelReasonListBean>> = MutableLiveData()

    //快递信息
    var logisticsInfoLD: MutableLiveData<LogisticeInfoBean> = MutableLiveData()

    //修改地址
    var changeAddressLD: MutableLiveData<Boolean> = MutableLiveData()

    //设置选中地址
    var setSelectAddressLD: MutableLiveData<Boolean> = MutableLiveData()

    //确认收货
    var confirmReciveLD: MutableLiveData<ReceiveOrderBean> = MutableLiveData()

    var delOrderLD: MutableLiveData<Boolean> = MutableLiveData()

    //我的订单列表
    var orderDataLD: MutableLiveData<BasicListBean<MyOrderListBean>> = MutableLiveData()

    //猜你喜欢 商品  分页列表
    var guessYouLikeLD: MutableLiveData<BasicListBean<GoodListBean>> = MutableLiveData()

    //我的订单列表
    fun requestOrderList(status: Int?,keyword:String, page: Int) {
        NewReatilRequestManager.getInstance().reqMyOrderList(orderDataLD, status,keyword, page)
    }

    //订单详情 poId：商品订单id
    fun requestOrderDetail(poId: String) {
        NewReatilRequestManager.getInstance().requestOrderDetail(orderLoadDetailLD, poId)

    }

    //确认订单---从商品详情进入
    fun reqCommitOrder4GoodsDetail(
        num: String,
        skuId: String,
        useScoreStatus: Int,
        userAddressId: Int,
        desc: String
    ) {
        NewReatilRequestManager.getInstance()
            .reqCommitOrder4GoodsDetail(commitOrderLD, num, skuId, useScoreStatus, userAddressId, desc)
    }

    //确认订单---从购物车进入
    fun reqCommitOrder4Cart(
        cartIds: String,
        useScoreStatus: Int,
        userAddressId: Int,
        descJson: String
    ) {
        NewReatilRequestManager.getInstance()
            .reqCommitOrder4Cart(commitOrderLD, cartIds, useScoreStatus, userAddressId, descJson)
    }

    //确认订单---纯酒币创建订单
    fun reqCreateScoreOrder(poids: String) {
        NewReatilRequestManager.getInstance().reqCreateScoreOrder(onlyScoreOrderLD, poids)
    }

    // 地址列表
    fun requestAddressList() {
        NewReatilRequestManager.getInstance().requestAddressList(addressDataLD)
    }

    //从sku到确认下单页（订单预处理）【确认订单的详情】
    fun requestConfirmOrderDetail4GoodsDetail(num: String, skuId: String) {
        NewReatilRequestManager.getInstance()
            .requestConfirmOrderDetail4GoodsDetail(orderDetailLD, num, skuId)
    }

    //从购物车到确认下单页（订单预处理）【确认订单的详情】
    fun requestConfirmOrderDetail4Cart(cartIds: String) {
        NewReatilRequestManager.getInstance().requestConfirmOrderDetail4Cart(orderDetailLD, cartIds)
    }

    //客户端关闭未支付超时订单
    fun requestOverTimeNoPayCancel(poId: String) {
        NewReatilRequestManager.getInstance().requestOverTimeNoPayCancel(overTimeCancelLD, poId)
    }

    //用户取消订单
    fun reqCancelOrder(poId: String, cancellationId: Int, rollbackCart: Int) {
        NewReatilRequestManager.getInstance()
            .reqCancelOrder(cancelOrderLD, poId, cancellationId, rollbackCart)
    }

    //删除订单
    fun requestDelOrder(poId: String) {
        NewReatilRequestManager.getInstance().reqDeleteOrder(delOrderLD, poId)
    }

    //取消原因列表
    fun reqCancelOrderReasonList() {
        NewReatilRequestManager.getInstance().reqCancelOrderReasonList(cancelOrderReasonLD)
    }

    //快递信息
    fun reqLogisticsInfo(poid: String) {
        NewReatilRequestManager.getInstance().reqLogisticsInfo(poid, logisticsInfoLD)
    }

    //修改地址
    fun reqChangeReciveAddress(poId: String, userAddressId: Int) {
        NewReatilRequestManager.getInstance()
            .reqChangeReciveAddress(poId, userAddressId, changeAddressLD)
    }

    //设置选中地址
    fun reqSetSelectAddress(userAddressId: Int) {
        NewReatilRequestManager.getInstance().reqSetSelectAddress(userAddressId, setSelectAddressLD)
    }

    //确认收货
    fun requestConfirmRecive(poId: String) {
        NewReatilRequestManager.getInstance().requestConfirmRecive(confirmReciveLD, poId)
    }

    //自动确认收货（客户端倒计时结束调用）
    fun requestOverTimeAutoReceive(poId: String) {
        NewReatilRequestManager.getInstance().requestOverTimeAutoReceive(overTimeReceiveLD, poId)
    }

    /**
     *订单列表占位--猜你喜欢 商品  分页列表
     */
    fun reqGuessYouLikeGoodList(page: Int) {
        NewReatilRequestManager.getInstance().reqRecommendGoods(guessYouLikeLD, "", 3, 0, page, 20)
    }
}